package org.example.lease.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.example.lease.mapper.UserInfoMapper;
import org.example.lease.model.entities.UserInfo;
import org.example.lease.model.enums.BaseStatus;
import org.example.lease.service.UserInfoService;
import org.example.lease.vo.user.UserInfoQueryVo;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 宋孟林
 * @description
 * @date: 2025/5/12 16:52
 */
@Service
@Slf4j
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
        implements UserInfoService {
    @Resource
    private UserInfoMapper userInfoMapper;

    @Override
    public IPage<UserInfo> pageUserInfo(IPage<UserInfo> userInfoIpage, UserInfoQueryVo userInfoQueryVo) {
        String phone = userInfoQueryVo.getPhone();
        BaseStatus status = userInfoQueryVo.getStatus();
        userInfoMapper.selectPage(userInfoIpage, Wrappers.lambdaQuery(UserInfo.class)
                .eq(phone != null, UserInfo::getPhone, phone)
                .eq(status != null, UserInfo::getStatus, userInfoQueryVo.getStatus()));
        log.info("分页对象数据内容为： {}", userInfoIpage.getRecords());
        return userInfoIpage;
    }
}




